In this demo, you will learn about the styling
component using Cascading Style Sheets or CSS
files as module in React. When working with Style Sheets' enlarged web applications, sometimes naming classes can be challenging and may
cause conflicts. By using CSS modules, you can make CSS classes
locally scoped to a component. Now, what is a CSS module? A CSS module is a CSS file
that when imported has every class name and
animation inside it scoped locally to the component
that is importing it. CSS module helps in avoiding
conflicts in naming classes. You will now use CSS modules. There's a boilerplate already
created with one component. The component includes
headings with H1 and H4 tags
wrapped inside a div, which is further
wrapped in a section. First, create a
CSS file following the name dot module
dot CSS convention, where the name will
be the name of the CSS file you prefer. Add CSS classes to the file. Next, import the component
1 dot module dot CSS that you have just created from within
your component one. Add import style from component
1 dot module dot CSS. To use the classes defined in component 1 dot module dot CSS, refer to the classes as a normal property from
the styles object. For the section tag, define a class name is equal
to styles dot section 1. Similarly, for the div tag
called a wrapper property from the styles object implied
two styles dot wrapper. Check whether the
styles are applied to the component by running
the application. In the outcome, the application loads with the applied styling fetched from the CSS
module. Thank you.